package org.demo.test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.boxlayout.gui.BoxLayoutEngine;
import org.boxlayout.gui.BoxLayoutFrame;
import org.boxlayout.gui.VisualElement;
import org.boxlayout.gui.type.ColorEnum;
import org.boxlayout.input.keyboard.KeyboardEvent;
import org.boxlayout.input.keyboard.KeyboardListener;

public class OrthoProjection   {


	public OrthoProjection() {
		
		
		final Log log = LogFactory.getLog("main");
		PropertyConfigurator.configure("log4j.properties");
		BoxLayoutFrame blf  = new BoxLayoutFrame();
		final BoxLayoutEngine ble = blf.getBoxLayoutEngine();
		ble.setOrtho(true);
		Float[] body = {2f,-2f,5f};
		Float[] target = {2f,-2f,0f};
		ble.getCamera().setBodyPosition(body);
		ble.getCamera().setTargetPosition(target);
		
		ble.addKeyListener(new KeyboardListener() {
			
			@Override
			public void onEvent(KeyboardEvent keyEvent) {
				//System.out.println(keyEvent.getKeyEvent().getKeyCode());
				if(keyEvent.getKeyEvent().getKeyCode()==0&&keyEvent.getType()==KeyboardEvent.Type.PRESSED){
					System.out.println(ble.getRootElement().serializeToText("  "));
				}
				
			}
		});
		//ble.updateKeyListeners();
		
		
		VisualElement root = ble.createElement().setColor(ColorEnum.BLUE).setWidth(1f).setHeight(1f).setAlpha(1f).setText("Hello comment cça va je m'appel Bob")
		.setX(-3f).setY(3f).setZ(0.001f)
		;
		
		
	
		//VisualElement ve = ble.createElement();
		//final VisualElement root = ble.createElement().setColor(ColorEnum.GREEN)
		//.setLayout(LayoutFactory.getInstance().getFloatingLayout())
		//.setInnerLayout(new InnerLayout())
		//.setPreferedWidth(2.0f).setPreferedHeight(2.0f)
		//.setZ(-1.0f)
		//.setName("root");
	


		ble.setRootElement(root);

		

		log.debug(" test"+root.serializeToText("  "));
		
		

	}




	public static void main(String[] args) {
		new OrthoProjection();

	}

}
